package com.ruoyi.project.business.socialsecurity.controller;

import java.util.List;

import com.ruoyi.project.business.socialsecurity.request.FindLikeCityNameRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.business.socialsecurity.entity.SysSocialSecurity;
import com.ruoyi.project.business.socialsecurity.request.ListSysSocialSecurityRequest;
import com.ruoyi.project.business.socialsecurity.request.AddSysSocialSecurityRequest;
import com.ruoyi.project.business.socialsecurity.response.SysSocialSecurityResponse;
import com.ruoyi.project.business.socialsecurity.service.ISysSocialSecurityService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.model.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 平台级每年社保基数维护Controller
 * 
 * @author ${author}
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/business/socialsecurity")
public class SysSocialSecurityController extends BaseController {
    @Autowired
    private ISysSocialSecurityService sysSocialSecurityService;

    /**
     * 查询平台级每年社保基数维护列表
     */
    @PreAuthorize("@ss.hasPermi('business:socialsecurity:list')")
    @GetMapping("/list")
    public TableDataInfo list(ListSysSocialSecurityRequest request) {
        startPage();
        List<SysSocialSecurityResponse> list = sysSocialSecurityService.selectSysSocialSecurityList(request);
        return getDataTable(list);
    }



    /**
     * 导出平台级每年社保基数维护列表
     */
    @PreAuthorize("@ss.hasPermi('business:socialsecurity:export')")
    @Log(title = "平台级每年社保基数维护", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ListSysSocialSecurityRequest request) {
        
        List<SysSocialSecurityResponse> list = sysSocialSecurityService.selectSysSocialSecurityList(request);
        ExcelUtil<SysSocialSecurityResponse> util = new ExcelUtil<>(SysSocialSecurityResponse.class);
        return util.exportExcel(list, "socialsecurity");
    }

    /**
     * 获取平台级每年社保基数维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:socialsecurity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sysSocialSecurityService.selectSysSocialSecurityById(id));
    }

    /**
     * 新增平台级每年社保基数维护
     */
    @PreAuthorize("@ss.hasPermi('business:socialsecurity:add')")
    @Log(title = "平台级每年社保基数维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AddSysSocialSecurityRequest request) {
        
        Long operatorId = getUserId();
        return toAjax(sysSocialSecurityService.insertSysSocialSecurity(request, operatorId));
    }

    /**
     * 修改平台级每年社保基数维护
     */
    @PreAuthorize("@ss.hasPermi('business:socialsecurity:edit')")
    @Log(title = "平台级每年社保基数维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSocialSecurity sysSocialSecurity) {
        
        Long operatorId = getUserId();
        return toAjax(sysSocialSecurityService.updateSysSocialSecurity(sysSocialSecurity, operatorId));
    }

    /**
     * 删除平台级每年社保基数维护
     */
    @PreAuthorize("@ss.hasPermi('business:socialsecurity:remove')")
    @Log(title = "平台级每年社保基数维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        
        Long operatorId = getUserId();
        return toAjax(sysSocialSecurityService.deleteSysSocialSecurityByIds(ids, operatorId));
    }
}
